home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 41.zip / BS1 part 41 / Abacus diskdrives IO.adf / Assembler / diskmon.s < prev    next >
Text File  |  1978-06-28  |  31KB  |  1,118 lines

  1. ;Diskmon.s Abacus Amiga Disk Drives Inside and Out
  2. ;Assemble with AssemPro Amiga, make sure Optmize BAckward Bcc's is OFF
  3. Exodus:
  4. OldOpenLibrary       =-408
  5. CloseLibrary         =-414
  6. AllocMem             =-198
  7. FreeMem              =-210
  8. Read                 = -42
  9. Write                = -48
  10. Open                 = -30
  11. Close                = -36
  12. FindTask             =-294
  13. OpenDevice           =-444
  14. CloseDevice          =-450
  15. DoIO                 =-456
  16.  
  17.         tst.l d0                ;parameter length
  18.         beq.s run
  19.         cmp.l #5,d0
  20.         bne.s run
  21.         cmp.b #"d",(a0)         ;test for "dfx:"
  22.         bne.s run
  23.         cmp.b #"f",1(a0)
  24.         bne.s run
  25.         cmp.b #":",3(a0)
  26.         bne.s run
  27.         move.b 2(a0),d0
  28.         sub.b #"0",d0
  29.         move.b d0,device        ;SET DRIVE
  30. run:    move.l 4,a6             ;dos.library open
  31.         lea dosname,a1
  32.         jsr OldOpenLibrary(a6)
  33.         move.l d0,dosbase
  34.         beq error
  35.         move.l #$10002,d1       ;512 byte buffer in chipmem
  36.         move.l #512,d0          ;reserved
  37.         jsr AllocMem(a6)
  38.         move.l d0,buffer
  39.         beq error
  40.         sub.l a1,a1             ;task for trackdisk.device
  41.         jsr FindTask(a6)
  42.         lea diskport,a0
  43.         move.l d0,16(a0)
  44.         clr.l d0
  45.         move.b device,d0        ;trackdisk.device for dfx: open
  46.         moveq #0,d1
  47.         lea diskioreq,a1
  48.         lea trkdisk,a0
  49.         jsr OpenDevice(a6)
  50.         tst.l d0
  51.         bne nodrive             ;close library,release memory
  52.         move.b device,d0        ;ldrive in command line set
  53.         add.b #"0",d0
  54.         move.b d0,drive
  55.         move.l dosbase,a6       ;open raw-window
  56.         move.l #title,d1
  57.         move.l #1005,d2
  58.         jsr Open(a6)
  59.         move.l d0,wdhd          ;windowhandle
  60.         beq error
  61.         jsr crsroff             ;cursor off
  62.         move.l wdhd,d1          ;menu display
  63.         move.l #top,d2
  64.         move.l #toplen,d3
  65.         jsr Write(a6)
  66.  
  67.         jsr dumpblock           ;output block # and $,clr errors
  68.         move.b #"r",key         ;simlulate read command
  69.         bra.s start
  70.  
  71. main:   jsr dumptype            ;typ output
  72.         jsr dumpcheck           ;checksum output
  73.         jsr getkey              ;get next key
  74. start:  cmp.b #$1b,key          ;program end
  75.         beq.s quit
  76.         cmp.b #"r",key          ;read block and display
  77.         beq readsec        cmp.b #"w",key          ;write blockand display
  78.         beq writesec        cmp.b #"c",key          ;data checksum create
  79.         beq check        cmp.b #"#",key          ;decimal block input and read
  80.         beq blockedit        cmp.b #"$",key          ;hexadecimal block input and read
  81.         beq blockedithex        cmp.b #"+",key          ;block +1 read
  82.         beq up        cmp.b #"-",key          ;block -1 read
  83.         beq down        cmp.b #"a",key          ;ascii input
  84.  
  85.         beq asciiedit        cmp.b #"h",key          ;hex input
  86.         beq hexedit        bne main
  87. quit:   move.l dosbase,a6       ;close window
  88.         move.l wdhd,d1
  89.         jsr Close(a6)
  90.  
  91.         move.l 4,a6             ;close trackdisk.device
  92.         lea diskioreq,a1
  93.         jsr CloseDevice(a6)
  94.  
  95. nodrive:move.l buffer,a1        ;free buffer
  96.         move.l #512,d0
  97.         jsr FreeMem(a6)
  98.  
  99.         move.l dosbase,a1       ;close dos.library
  100.         jsr CloseLibrary(a6)
  101.         clr.l d0
  102.         rts
  103.  
  104. error:  moveq #100,d0           ;returncode 100 for system error
  105.         rts
  106.  
  107. dumphex:cmp.b #"a",key          ;ascii input- NTSC added
  108.         beq hexstop             ;NTSC added
  109.         move.b #"0",row         ;cursor pos.
  110.         move.b #"6",row+1
  111.         move.b #"0",col
  112.         move.b #"2",col+1
  113.         move.l buffer,buffptr   ;buffer pointer to start
  114.         clr.w adr
  115.         moveq #15,d6            ;16 lines
  116. poshex: jsr cursor              ;address output
  117.         move.w adr,d0
  118.         jsr convword
  119.         jsr printword
  120.         move.b #" ",key         ;space printed
  121.         jsr printkey
  122.         add.w #$20,adr          ;inc. address by $20
  123.         moveq #15,d5            ;16 words per line
  124.         lea linebuf,a2          ;buffer for line
  125. x:      move.l buffptr,a1
  126.         add.l #2,buffptr        ;buffer pointer2
  127.         move.w (a1),d0          ;get word
  128.         jsr convword            ;convert to ascii
  129.         move.l mytext,(a2)+     ;copy to line buffer
  130.         dbra d5,x
  131.         jsr printline
  132.         move.b row+1,d0         ;cursor pos. line +1
  133.         cmp.b #"9",d0
  134.         bne.s l1
  135.         add.b #1,row
  136.         move.b #"0"-1,row+1
  137. l1:     add.b #1,row+1
  138.         dbra d6,poshex
  139. hexstop: rts
  140.  
  141. convdez:lea mytext,a0           ;convert word in d0 by 4
  142.         divu #1000,d0           ;decimal number
  143.         add.b #"0",d0
  144.         move.b d0,(a0)+
  145.         clr.w d0
  146.         swap d0
  147.         divu #100,d0
  148.         add.b #"0",d0
  149.         move.b d0,(a0)+
  150.         clr.w d0
  151.         swap d0
  152.         divu #10,d0
  153.         add.b #"0",d0
  154.         move.b d0,(a0)+
  155.         clr.w d0
  156.         swap d0
  157.         add.b #"0",d0
  158.         move.b d0,(a0)+
  159.         rts
  160.  
  161. convword:                       ;convert word in d0 to ascii text
  162.         moveq #3,d2
  163.         lea mytext+4,a0
  164. l0:     move.b d0,d1
  165.         and.b #$0f,d1
  166.         lsr.w #4,d0
  167.         cmp.b #$09,d1
  168.         bgt.s hex
  169.         add.b #"0",d1
  170.         bra.s do
  171. hex:    add.b #"a"-10,d1
  172. do:     move.b d1,-(a0)
  173.         dbra d2,l0
  174.         rts
  175.  
  176. printword:                      ;text output
  177.         move.l wdhd,d1
  178.         move.l #mytext,d2
  179.         moveq #4,d3
  180.         jsr Write(a6)
  181.         rts
  182.  
  183. dumpasc:cmp.b #"h",key          ;check for hex display NTSC only
  184.         beq ascstop
  185.         move.b #"0",row         ;block ascii output Pal=2
  186.         move.b #"6",row+1       ;PAl =3
  187.         move.b #"0",col         ;PAL =0
  188.         move.b #"2",col+1       ;Pal =2
  189.         move.l buffer,buffptr   ;
  190.         clr.w adr               ;
  191.         moveq #7,d6             ; PAL=7
  192. posasc: jsr cursor              ;address output
  193.         move.w adr,d0
  194.         jsr convword
  195.         jsr printword
  196.         move.b #" ",key         ;space printed
  197.         jsr printkey
  198.         add.w #$40,adr
  199.         moveq #63,d5
  200.         lea linebuf,a2          ;line buffer
  201.         move.l buffptr,a1
  202. y:      move.b (a1)+,d0         ;get byte and mask ascii
  203.         cmp.b #" ",d0
  204.         blt.s dot
  205.         cmp.b #"z",d0
  206.         bgt.s dot
  207.         move.b d0,(a2)+
  208.         bra.s chr
  209. dot:    move.b #".",(a2)+       ;replace control char with "."
  210. chr:    dbra d5,y
  211.         move.l a1,buffptr
  212.         jsr printline           ;line buffer output
  213.         move.b row+1,d0         ;cursor pos. line +1
  214.         cmp.b #"9",d0
  215.         bne.s l2
  216.         add.b #1,row
  217.         move.b #"0"-1,row+1
  218. l2:     add.b #1,row+1
  219.         dbra d6,posasc
  220.         move.l wdhd,d1             ;NTSC only to clear 8 hex lines
  221.         move.l #clrhex,d2          ;NTSC only
  222.         move.l #clrhexlen,d3       ;NTSC only
  223.         jsr Write(a6)              ;NTSC only
  224.  
  225.  
  226. ascstop:rts
  227.  
  228. printline:                      ;line buffer output
  229.         move.l wdhd,d1
  230.         move.l #linebuf,d2
  231.         moveq #64,d3
  232.         jsr Write(a6)
  233.         rts
  234.  
  235. dumpcheck:                      ;checksum output
  236.         move.b #"0",row
  237.         move.b #"4",row+1
  238.         move.b #"5",col
  239.         move.b #"1",col+1
  240.         jsr cursor
  241.         move.l buffer,a0        ;upper word
  242.         move.w 20(a0),d0
  243.         jsr convword
  244.         jsr printword
  245.         move.l buffer,a0        ;lower word
  246.         move.w 22(a0),d0
  247.         jsr convword
  248.         jsr printword
  249.         rts
  250.  
  251. dumpblock:                      ;block number dez. and hex. output
  252.         move.b #"0",row
  253.         move.b #"4",row+1
  254.         move.b #"0",col
  255.         move.b #"9",col+1
  256.         jsr cursor
  257.         move.w block,d0         ;set offset for read/write
  258.         mulu #512,d0
  259.         move.l d0,offset
  260.         clr.l d0
  261.         move.w block,d0
  262.         jsr convdez             ;convert block decimal
  263.         jsr printword
  264.         move.b #"0",row         ;convert block hex.
  265.         move.b #"4",row+1
  266.         move.b #"1",col
  267.         move.b #"5",col+1
  268.         jsr cursor
  269.         move.w block,d0
  270.         jsr convword
  271.         jsr printword
  272.  
  273.         move.l #clear,d4        ;clr error message
  274.         moveq #clrlen,d5
  275.         jsr doerr
  276.         rts
  277.  
  278. dumptype:
  279.         move.b #"0",row         ;block type output
  280.         move.b #"2",row+1
  281.         move.b #"0",col
  282.         move.b #"2",col+1
  283.         jsr cursor
  284.         move.l wdhd,d1
  285.         move.l #unkn,d2         ;typ unknown
  286.         moveq #10,d3            ;typ-lenght
  287.         cmp.w #2,block          ;boot       block=0,1
  288.         bge.s noboot
  289.         move.l #boot,d2
  290.         bra.s noknown
  291. noboot: move.l buffer,a0
  292.         cmp.l #8,(a0)           ;data       1.LW=$00000008
  293.         bne.s nodata
  294.         move.l #dat,d2
  295. nodata: cmp.l #$10,(a0)         ;filelist   1.LW=$00000010
  296.         bne.s nolisting
  297.         cmp.l #-3,508(a0)       ;filelist 127.LW=$fffffffd
  298.         bne.s nolisting
  299.         move.l #flist,d2
  300. nolisting: cmp.l #2,(a0)        ;root,userdir,filehead
  301.                                 ;           1.LW=$00000002
  302.         bne.s noknown
  303.         cmp.l #1,508(a0)        ;root     127.LW=$00000001
  304.         bne.s noroot
  305.         move.l #root,d2
  306. noroot: cmp.l #2,508(a0)        ;userdir  127.LW=$00000002
  307.         bne.s noudir
  308.         move.l #udir,d2
  309. noudir: cmp.l #-3,508(a0)       ;filehead 127.LW=$fffffffd
  310.         bne.s noknown
  311.         move.l #fhead,d2
  312. noknown:jsr Write(a6)
  313.         rts
  314.  
  315. getkey: move.l wdhd,d1          ;wait for key
  316.         move.l #key,d2          ;get next key
  317.         moveq #1,d3
  318.         jsr Read(a6)
  319.         rts
  320.  
  321. printkey:                       ;char key printed
  322.         move.l wdhd,d1
  323.         move.l #key,d2
  324.         moveq #1,d3
  325.         jsr Write(a6)
  326.         rts
  327.  
  328. cursor: jsr cursoff             ;cursor off, no status change
  329.         move.l wdhd,d1          ;cursor on #address position
  330.         move.l #adrpos,d2
  331.         moveq #7,d3
  332.         jsr Write(a6)
  333.         lea mytext,a0
  334.         move.l #"    ",(a0)
  335.         btst #0,crsrstatus      ;when cursor off,clr address
  336.         beq.s noadr
  337.         move.l buffptr,d0       ;else output address
  338.         sub.l buffer,d0         ;address=pointer-start
  339.         jsr convdez
  340. noadr:  jsr printword
  341.         move.l wdhd,d1          ;position cursor on $address
  342.         move.l #adrpos2,d2
  343.         moveq #7,d3
  344.         jsr Write(a6)
  345.         lea mytext,a0
  346.         move.l #"    ",(a0)
  347.         btst #0,crsrstatus      ;when cursor off, clr address
  348.         beq.s noadr2
  349.         move.l buffptr,d0       ;else output address
  350.         sub.l buffer,d0
  351.         jsr convword
  352. noadr2: jsr printword
  353.         move.l wdhd,d1          ;cursor position
  354.         move.l #pos,d2
  355.         moveq #7,d3
  356.         jsr Write(a6)
  357.         btst #0,crsrstatus
  358.         beq.s no
  359.         jsr curson              ;cursor on. no status change
  360. no:     rts
  361.  
  362. crsron: bset #0,crsrstatus      ;switch cursor on
  363. curson: move.l wdhd,d1
  364.         move.l #con,d2
  365.         moveq #3,d3
  366.         jsr Write(a6)
  367.         rts
  368.  
  369. crsroff:bclr #0,crsrstatus      ;switch cursor off
  370. cursoff:move.l wdhd,d1
  371.         move.l #coff,d2
  372.         moveq #4,d3
  373.         jsr Write(a6)
  374.         rts
  375.  
  376. doerr:  move.l dosbase,a6       ;output error message d4/d5
  377.         move.b #"0",row
  378.         move.b #"4",row+1
  379.         move.b #"6",col
  380.         move.b #"0",col+1
  381.         jsr cursor
  382.         move.l wdhd,d1
  383.         move.l d4,d2
  384.         move.l d5,d3
  385.         jsr Write(a6)
  386.         lea diskioreq,a0        ;clr error status
  387.         clr.l 32(a0)
  388.         rts
  389.  
  390. mtroff: move.l 4,a6             ;switch motor off
  391.         lea diskioreq,a1
  392.         move.w #9,28(a1)        ;motor on
  393.         clr.l 36(a1)
  394.         jsr DoIO(a6)
  395.         move.l dosbase,a6
  396.         rts
  397.  
  398. readsec:move.l 4,a6             ;read block into buffer
  399.         lea diskioreq,a1
  400.         move.w #14,28(a1)       ;test is  disk inserted
  401.         jsr DoIO(a6)
  402.         lea diskioreq,a1
  403.         tst.l 32(a1)
  404.         beq.s dsk
  405.  
  406.         move.l #nderr,d4        ;output error
  407.         moveq #ndlen,d5
  408.         jsr doerr
  409.         bra here                ;read finished
  410.  
  411. dsk:    lea diskioreq,a1        ;block read
  412.         move.w #2,28(a1)
  413.         move.l #512,36(a1)
  414.         move.l buffer,40(a1)
  415.         move.l offset,44(a1)
  416.         jsr DoIO(a6)
  417.         tst.l d0                ;test for read error
  418.         beq.s noerr
  419.  
  420.         move.l #rderr,d4        ;error output
  421.         moveq #rdlen,d5
  422.         jsr doerr
  423.         bra.s here
  424.  
  425. noerr:  jsr dumpblock           ;output block number,clr error
  426. here:   jsr mtroff
  427.         jsr dumpcheck           ;checksum
  428.         jsr dumptype            ;type
  429.         cmp.b #"a",key          ;ascii input  NTSC added
  430.         jsr dumpasc             ;               NTSC added
  431.  
  432.         cmp.b #"h",key          ;hex input    NTSC added
  433.  
  434.         jsr dumphex             ;hex. output
  435. ;       jsr dumpasc             ;ascii output orginal pal
  436.         bra main
  437.  
  438. writesec:                       ;write block to disk
  439.         move.l 4,a6
  440.         lea diskioreq,a1
  441.         move.w #14,28(a1)       ;test if disk inserted
  442.         jsr DoIO(a6)
  443.         lea diskioreq,a1
  444.         tst.l 32(a1)
  445.         beq.s dsk2
  446.  
  447.         move.l #nderr,d4        ;error output
  448.         moveq #ndlen,d5
  449.         jsr doerr
  450.         bra here2
  451.  
  452. dsk2:   lea diskioreq,a1
  453.         move.w #15,28(a1)       ;test for write-protect
  454.         jsr DoIO(a6)
  455.         lea diskioreq,a1
  456.         tst.l 32(a1)
  457.         beq.s dsk3
  458.  
  459.         move.l #pterr,d4        ;error output
  460.         moveq #ptlen,d5
  461.         jsr doerr
  462.         bra here2
  463.  
  464. dsk3:   move.w #3,28(a1)        ;block write
  465.         move.l #512,36(a1)
  466.         move.l buffer,40(a1)
  467.         move.l offset,44(a1)
  468.         jsr DoIO(a6)
  469.         lea diskioreq,a1
  470.         move.w #4,28(a1)        ;update disk
  471.         move.l #512,36(a1)
  472.         move.l buffer,40(a1)
  473.         move.l offset,44(a1)
  474.         jsr DoIO(a6)
  475.         tst.l d0                ;test for write error
  476.         beq.s noerr2
  477.  
  478.         move.l #wrerr,d4        ;error output
  479.         moveq #wrlen,d5
  480.         jsr doerr
  481.         bra.s here2
  482.  
  483. noerr2: jsr dumpblock           ;output everything
  484. here2:  jsr mtroff
  485.         jsr dumpcheck
  486.         jsr dumphex
  487.         jsr dumpasc
  488.         bra main
  489.  
  490. check:  move.l buffer,a0        ;calculate buffer checksum
  491.         moveq #126,d0
  492.         clr.l d1
  493. adck:   cmp.w #121,d0           ;jump over checksum
  494.         bne.s ck
  495.         add.l #4,a0
  496. ck:     sub.l (a0)+,d1
  497.         dbra d0,adck
  498.         move.l buffer,a0        ;record checksum
  499.         move.l d1,20(a0)
  500.         jsr dumpcheck           ;output
  501.         jsr dumphex
  502.         jsr dumpasc
  503.         bra main
  504.  
  505. blockedit:                      ;input block number in dec.
  506.         move.b #"0",row
  507.         move.b #"4",row+1
  508.         move.b #"0",col
  509.         move.b #"9",col+1
  510.         jsr cursor
  511.         jsr crsron
  512.         moveq #3,d4             ;4 chars
  513.         lea mytext,a5
  514. in:     jsr getkey
  515.         cmp.b #"0",key
  516.         blt.s in
  517.         cmp.b #"9",key
  518.         bgt.s in
  519.         jsr printkey
  520.         move.b key,(a5)+        ;in text buffer
  521.         dbra d4,in
  522.         jsr crsroff
  523.         clr.w block             ;convert text buffer to hex
  524.         lea mytext,a0
  525.         clr.w d0
  526.         move.b (a0)+,d0
  527.         sub.w #"0",d0
  528.         mulu #1000,d0
  529.         add.w d0,block
  530.         clr.w d0
  531.         move.b (a0)+,d0
  532.         sub.w #"0",d0
  533.         mulu #100,d0
  534.         add.w d0,block
  535.         clr.w d0
  536.         move.b (a0)+,d0
  537.         sub.w #"0",d0
  538.         mulu #10,d0
  539.         add.w d0,block
  540.         clr.w d0
  541.         move.b (a0)+,d0
  542.         sub.w #"0",d0
  543.         add.w d0,block
  544.         cmp.w #1759,block     ;compare with last block
  545.         bgt blockedit         ;new input
  546.         jsr dumpblock
  547.         bra readsec           ;read blockand display
  548.  
  549. blockedithex:                   ;input block in hex
  550.         move.b #"0",row
  551.         move.b #"4",row+1
  552.         move.b #"1",col
  553.         move.b #"5",col+1
  554.         jsr cursor
  555.         jsr crsron
  556.         lea mytext,a5
  557.         moveq #3,d4             ;4 char
  558. retry:  jsr getkey
  559.         cmp.b #"0",key
  560.         blt retry        cmp.b #"f",key
  561.         bgt retry        cmp.b #"9",key
  562.         ble.s h0
  563.         cmp.b #"a",key
  564.         bge.s h0
  565.         bra.s retry
  566. h0:     jsr printkey
  567.         move.b key,(a5)+        ;write in text buffer
  568.         dbra d4,retry
  569.         jsr crsroff
  570.         move.b mytext,d0        ;convert text to hex in nibbles
  571.         cmp.b #"9",d0
  572.         bgt.s h1
  573.         sub.b #"0"-"a"+10,d0
  574. h1:     sub.b #"a"-10,d0
  575.         lsl.b #4,d0
  576.         move.b d0,block
  577.         move.b mytext+1,d0
  578.         cmp.b #"9",d0
  579.         bgt.s h2
  580.         sub.b #"0"-"a"+10,d0
  581. h2:     sub.b #"a"-10,d0
  582.         or.b d0,block
  583.         move.b mytext+2,d0
  584.         cmp.b #"9",d0
  585.         bgt.s h3
  586.         sub.b #"0"-"a"+10,d0
  587. h3:     sub.b #"a"-10,d0
  588.         lsl.b #4,d0
  589.         move.b d0,block+1
  590.         move.b mytext+3,d0
  591.         cmp.b #"9",d0
  592.         bgt.s h4
  593.         sub.b #"0"-"a"+10,d0
  594. h4:     sub.b #"a"-10,d0
  595.         or.b d0,block+1
  596.         cmp.w #1759,block       ;compare with last block
  597.         bgt blockedithex        jsr dumpblock           ;block output
  598.         bra readsec           ;read block and display
  599.  
  600. up:     cmp.w #1759,block       ;read next block and display
  601.         beq main        add.w #1,block
  602.         jsr dumpblock
  603.         jmp readsec
  604.  
  605. down:   tst.w block             ;previous block read and disp.
  606.         beq main        sub.w #1,block
  607.         jsr dumpblock
  608.         jmp readsec
  609.  
  610. asciiedit: jsr dumpasc          ;ascii input in buffer
  611.         move.b #"0",row         ;PAL =2
  612.         move.b #"6",row+1       ;PAl =3
  613.         move.b #"0",col         ;PAL =0
  614.         move.b #"7",col+1       ;PAL =7
  615.         move.l buffer,buffptr
  616.         jsr crsron
  617.         jsr cursor
  618. getasc: jsr getkey
  619.  
  620.         cmp.b #$9b,key          ;compare with cursor sequence
  621.         bne nocurs        jsr getkey
  622.         cmp.b #$44,key          ;left
  623.         beq ascleft        cmp.b #$43,key          ;right
  624.         beq ascright        cmp.b #$41,key          ;up
  625.         beq ascup
  626.         cmp.b #$42,key          ;down
  627.         beq ascdown
  628.         bra.s getasc
  629.  
  630. ascright:                       ;cursor right or start of line
  631.         cmp.b #"7",col
  632.         blt.s csright
  633.         cmp.b #"0",col+1
  634.         blt.s csright
  635.         cmp.b #"3",row
  636.         blt csdown        cmp.b #"0",row+1
  637.         blt csdown        bra getasc            ;cursor in lower left
  638.  
  639. csright:cmp.b #"9",col+1        ;set cursor
  640.         bne.s m3
  641.         move.b #"0"-1,col+1
  642.         add.b #1,col
  643. m3:     add.b #1,col+1
  644.         add.l #1,buffptr        ;set buffer pointer
  645.         jsr cursor
  646.         bra getasc
  647.  
  648. csdown: cmp.b #"9",row+1        ;see above
  649.         bne.s m2
  650.         move.b #"0"-1,row+1
  651.         add.b #1,row
  652. m2:     add.b #1,row+1
  653.         move.b #"0",col
  654.         move.b #"7",col+1
  655.         add.l #1,buffptr
  656.         jsr cursor
  657.         bra getasc
  658.  
  659. ascdown:cmp.b #"3",row          ;cursor down if possible
  660.         blt rowdown        cmp.b #"0",row+1
  661.         blt rowdown        bra getasc
  662.  
  663. rowdown:cmp.b #"9",row+1
  664.         bne.s m4
  665.         move.b #"0"-1,row+1
  666.         add.b #1,row
  667. m4:     add.b #1,row+1
  668.         add.l #$40,buffptr      ;buffer pointer next line
  669.         jsr cursor
  670.         bra getasc
  671.  
  672. ascleft:cmp.b #"0",col          ;cursor left or end of line
  673.         bgt.s csleft
  674.         cmp.b #"7",col+1
  675.         bgt.s csleft
  676.         cmp.b #"2",row
  677.         bgt csup        cmp.b #"3",row+1
  678.         bgt csup
  679.         bra getasc              ;cursor is upper left
  680.  
  681. csleft: cmp.b #"0",col+1        ;set cursor
  682.         bne.s m5
  683.         move.b #"9"+1,col+1
  684.         sub.b #1,col
  685. m5:     sub.b #1,col+1
  686.         sub.l #1,buffptr        ;left buffer pointer
  687.         jsr cursor
  688.         bra getasc
  689.  
  690. csup:   cmp.b #"0",row+1        ;cursor to end of line
  691.         bne.s m6
  692.         move.b #"9"+1,row+1
  693.         sub.b #1,row
  694. m6:     sub.b #1,row+1
  695.         move.b #"7",col
  696.         move.b #"0",col+1
  697.         sub.l #1,buffptr
  698.         jsr cursor
  699.         bra getasc
  700.  
  701. ascup:  cmp.b #"2",row          ;cursor up if possible
  702.         bgt rowup
  703.         cmp.b #"3",row+1
  704.         bgt rowup
  705.         bra getasc
  706.  
  707. rowup:  cmp.b #"0",row+1
  708.         bne.s m8
  709.         move.b #"9"+1,row+1
  710.         sub.b #1,row
  711. m8:     sub.b #1,row+1
  712.         sub.l #$40,buffptr      ;buffer pointer upper line
  713.         jsr cursor
  714.         bra getasc
  715.  
  716. nocurs: cmp.b #$1b,key          ;escape key= end input
  717.         beq ascend    
  718.         cmp.b #" ",key          ;mask key
  719.         blt getasc
  720.         cmp.b #"z",key
  721.         bgt getasc
  722.  
  723.         cmp.b #"7",col          ;char left or start of line
  724.         blt.s doright           ;print
  725.         cmp.b #"0",col+1
  726.         blt.s doright
  727.         cmp.b #"3",row
  728.         blt dodown
  729.         cmp.b #"0",row+1
  730.         blt dodown
  731.         jsr printkey
  732.         move.l buffptr,a0       ;store in buffer
  733.         move.b key,(a0)
  734.         bra asciiedit           ;cursor home
  735.  
  736. doright:cmp.b #"9",col+1        ;char left print
  737.         bne.s m0
  738.         move.b #"0"-1,col+1
  739.         add.b #1,col
  740. m0:     add.b #1,col+1
  741.         jsr printkey
  742.         move.l buffptr,a0
  743.         move.b key,(a0)         ;store in buffer
  744.         add.l #1,buffptr
  745.         jsr cursor
  746.         bra getasc
  747.  
  748. dodown: cmp.b #"9",row+1        ;print char at start of line
  749.         bne.s m1
  750.         move.b #"0"-1,row+1
  751.         add.b #1,row
  752. m1:     add.b #1,row+1
  753.         move.b #"0",col
  754.         move.b #"7",col+1
  755.         jsr printkey
  756.         move.l buffptr,a0
  757.         move.b key,(a0)         ;store in buffer
  758.         add.l #1,buffptr
  759.         jsr cursor
  760.         bra getasc
  761.  
  762. ascend: jsr crsroff             ;end the  ascii input
  763. ;       jsr dumphex             ;hex output PAL only
  764.         bra main
  765.  
  766. hexedit:jsr dumphex             ;added NTSC
  767.         move.b #"0",row         ;hex input in buffer
  768.         move.b #"6",row+1       ;similar to ascii input
  769.         move.b #"0",col         ;except:   cursor in 2 steps
  770.         move.b #"7",col+1       ;          to enter in bytes
  771.         move.l buffer,buffptr
  772.         jsr crsron
  773.         jsr cursor
  774. gethex: jsr getkey
  775.         cmp.b #$9b,key
  776.         bne noxcurs
  777.         jsr getkey
  778.         cmp.b #$44,key
  779.         beq hexleft
  780.         cmp.b #$43,key
  781.         beq hexright
  782.         cmp.b #$41,key
  783.         beq hexup
  784.         cmp.b #$42,key
  785.         beq hexdown
  786.         bra gethex
  787.  
  788. hexright:
  789.         cmp.b #"6",col
  790.         blt.s xcsright
  791.         cmp.b #"9",col+1
  792.         blt.s xcsright
  793.         cmp.b #"2",row
  794.         blt xcsdown
  795.         cmp.b #"1",row+1
  796.         blt xcsdown
  797.         bra gethex
  798.  
  799. xcsright:
  800.         cmp.b #"9",col+1
  801.         bne.s n3
  802.         move.b #"1"-2,col+1
  803.         add.b #1,col
  804. n3:     add.b #2,col+1
  805.         add.l #1,buffptr
  806.         jsr cursor
  807.         bra gethex
  808.  
  809. xcsdown:cmp.b #"9",row+1
  810.         bne.s n2
  811.         move.b #"0"-1,row+1
  812.         add.b #1,row
  813. n2:     add.b #1,row+1
  814.         move.b #"0",col
  815.         move.b #"7",col+1
  816.         add.l #1,buffptr
  817.         jsr cursor
  818.         bra gethex
  819.  
  820. hexdown:cmp.b #"2",row
  821.         blt rowxdown
  822.         cmp.b #"1",row+1
  823.         blt rowxdown
  824.         bra gethex
  825.  
  826. rowxdown:
  827.         cmp.b #"9",row+1
  828.         bne.s n4
  829.         move.b #"0"-1,row+1
  830.         add.b #1,row
  831. n4:     add.b #1,row+1
  832.         add.l #$20,buffptr
  833.         jsr cursor
  834.         bra gethex
  835.  
  836. hexleft:cmp.b #"0",col
  837.         bgt.s xcsleft
  838.         cmp.b #"7",col+1
  839.         bgt.s xcsleft
  840.         cmp.b #"0",row
  841.         bgt xcsup
  842.         cmp.b #"6",row+1
  843.         bgt xcsup
  844.         bra gethex
  845.  
  846. xcsleft:cmp.b #"1",col+1
  847.         bne.s n5
  848.         move.b #"9"+2,col+1
  849.         sub.b #1,col
  850. n5:     sub.b #2,col+1
  851.         sub.l #1,buffptr
  852.         jsr cursor
  853.         bra gethex
  854.  
  855. xcsup:  cmp.b #"0",row+1
  856.         bne.s n6
  857.         move.b #"9"+1,row+1
  858.         sub.b #1,row
  859. n6:     sub.b #1,row+1
  860.         move.b #"6",col
  861.         move.b #"9",col+1
  862.         sub.l #1,buffptr
  863.         jsr cursor
  864.         bra gethex
  865.  
  866. hexup:  cmp.b #"0",row
  867.         bgt xrowup
  868.         cmp.b #"6",row+1
  869.         bgt xrowup
  870.         bra gethex
  871.  
  872. xrowup: cmp.b #"0",row+1
  873.         bne.s n8
  874.         move.b #"9"+1,row+1
  875.         sub.b #1,row
  876. n8:     sub.b #1,row+1
  877.         sub.l #$20,buffptr
  878.         jsr cursor
  879.         bra gethex
  880.  
  881.  
  882. noxcurs:cmp.b #$1b,key
  883.         beq hexend    
  884.         cmp.b #"0",key
  885.         blt gethex
  886.         cmp.b #"f",key
  887.         bgt gethex
  888.         cmp.b #"9",key
  889.         ble.s ok0
  890.         cmp.b #"a",key
  891.         bge.s ok0
  892.         bra gethex
  893. ok0:    jsr printkey
  894. ok2:    move.l wdhd,d1
  895.         move.l #key2,d2
  896.         moveq #1,d3
  897.         jsr Read(a6)
  898.         cmp.b #"0",key2
  899.         blt.s ok2
  900.         cmp.b #"f",key2
  901.         bgt.s ok2
  902.         cmp.b #"9",key2
  903.         ble.s ok1
  904.         cmp.b #"a",key2
  905.         blt.s ok2
  906.         
  907. ok1:    move.b key,d0           ;convert key and key2 into byte
  908.         cmp.b #"9",d0
  909.         bgt.s ok3
  910.         sub.b #"0"-"a"+10,d0
  911. ok3:    sub.b #"a"-10,d0
  912.         lsl.b #4,d0
  913.         move.b d0,byte
  914.         move.b key2,d0
  915.         cmp.b #"9",d0
  916.         bgt.s ok4
  917.         sub.b #"0"-"a"+10,d0
  918. ok4:    sub.b #"a"-10,d0
  919.         or.b d0,byte
  920.  
  921.         cmp.b #"6",col
  922.         blt.s doxright
  923.         cmp.b #"9",col+1
  924.         blt.s doxright
  925.         cmp.b #"2",row
  926.         blt doxdown
  927.         cmp.b #"1",row+1
  928.         blt doxdown
  929.         move.l wdhd,d1
  930.         move.l #key2,d2
  931.         moveq #1,d3
  932.         jsr Write(a6)
  933.         move.l buffptr,a0
  934.         move.b byte,(a0)
  935.         bra hexedit
  936.  
  937. doxright:
  938.         cmp.b #"9",col+1
  939.         bne.s n0
  940.         move.b #"1"-2,col+1
  941.         add.b #1,col
  942. n0:     add.b #2,col+1
  943.         move.l wdhd,d1
  944.         move.l #key2,d2
  945.         moveq #1,d3
  946.         jsr Write(a6)
  947.         move.l buffptr,a0
  948.         move.b byte,(a0)
  949.         add.l #1,buffptr
  950.         jsr cursor
  951.         bra gethex
  952.  
  953. doxdown:cmp.b #"9",row+1
  954.         bne.s n1
  955.         move.b #"0"-1,row+1
  956.         add.b #1,row
  957. n1:     add.b #1,row+1
  958.         move.b #"0",col
  959.         move.b #"7",col+1
  960.         move.l wdhd,d1
  961.         move.l #key2,d2
  962.         moveq #1,d3
  963.         jsr Write(a6)
  964.         move.l buffptr,a0
  965.         move.b byte,(a0)
  966.         add.l #1,buffptr
  967.         jsr cursor
  968.         bra gethex
  969.  
  970. hexend: jsr crsroff             ;end hex input
  971. ;       jsr dumpasc             ;ascii output  PAL only
  972.         bra main
  973.  
  974. ;       TEXT, VARIABLES AND TABLE
  975.  
  976. title:  dc.b "raw:0/0/640/200/"
  977.         dc.b "      DISK-MONITOR VERSION 1.0    "
  978.         dc.b "      INSERT DISK TO EXAMINE IN DF"
  979. drive:  dc.b 0,":   ",0
  980. top:    dc.b $0a
  981.  
  982.         ;    invers               1.char        normal  rest
  983.  
  984.         dc.b "            "
  985.         dc.b " ",$9b,"0;31;43",$6d,"Esc",$9b,"0;31;40",$6d,"ape"
  986.         dc.b " ",$9b,"0;31;43",$6d,"#",$9b,"0;31;40",$6d," Block"
  987.         dc.b " ",$9b,"0;31;43",$6d,"$",$9b,"0;31;40",$6d," Block"
  988.         dc.b " ",$9b,"0;31;43",$6d,"+",$9b,"0;31;40",$6d," Up"
  989.         dc.b " ",$9b,"0;31;43",$6d,"-",$9b,"0;31;40",$6d," Down"
  990.         dc.b " ",$9b,"0;31;43",$6d,"R",$9b,"0;31;40",$6d,"ead"
  991.         dc.b " ",$9b,"0;31;43",$6d,"W",$9b,"0;31;40",$6d,"rite"
  992.         dc.b " ",$9b,"0;31;43",$6d,"C",$9b,"0;31;40",$6d,"hecksum"
  993.         dc.b " ",$9b,"0;31;43",$6d,"A",$9b,"0;31;40",$6d,"scii"
  994.         dc.b " ",$9b,"0;31;43",$6d,"H",$9b,"0;31;40",$6d,"ex"
  995.         dc.b $0a,$0a
  996.         dc.b " Block #     $      Buffer #     $      Checksum $"
  997.         dc.b $0a,"---------------------------------------------------"
  998.         dc.b "--------------------------"
  999. topend dc.b   1
  1000. toplen=topend-top
  1001.  
  1002.         ; BLOCKTYP
  1003.  
  1004. boot:   dc.b "BOOTBLOCK "
  1005. root:   dc.b "ROOTBLOCK "
  1006. flist:  dc.b "FILELIST  "
  1007. fhead:  dc.b "FILEHEADER"
  1008. dat:    dc.b "DATABLOCK "
  1009. udir:   dc.b "USERDIR   "
  1010. unkn:   dc.b "----------"
  1011.  
  1012.         ; DISK Error messages
  1013.  
  1014. nderr:  dc.b $9b,"43",$6d,"NO DISK IN DRIVE !",$9b,"40",$6d
  1015. nderrend: dc.b 1ndlen=nderrend-nderr
  1016. rderr:  dc.b $9b,"43",$6d,"   READ-ERROR !   ",$9b,"40",$6d
  1017. rdend:  dc.b 1rdlen=rdend-rderr
  1018. wrerr:  dc.b $9b,"43",$6d,"   WRITE-ERROR !  ",$9b,"40",$6d
  1019. wrend:  dc.b 1wrlen=wrend-wrerr
  1020. pterr:  dc.b $9b,"43",$6d,"WRITE-PROTECTION !",$9b,"40",$6d
  1021. ptend   dc.b 1ptlen=ptend-pterr
  1022. clear:  dc.b "    NO ERROR !    "
  1023. clrend  dc.b 1clrlen=clrend-clear
  1024.  
  1025.  
  1026.  align   ;evencrsrstatus:
  1027.         dc.w 0
  1028. adr:    dc.w 0
  1029. mytext:   dc.b "0000"
  1030. key:    dc.b 0
  1031. key2:   dc.b 0
  1032. byte:   dc.b 0
  1033.  align ;even
  1034. linebuf:blk.b 64,0      ;buffer for conversions
  1035.  
  1036.         ;sequence for cursor positioning
  1037.  
  1038. pos:    dc.b $9b
  1039. row:    dc.b "00",$3b
  1040. col:    dc.b "00",$48
  1041.  
  1042.         ;s.o. for address number dec and hex
  1043.  
  1044. adrpos: dc.b $9b,"04",$3b,"29",$48
  1045. adrpos2:dc.b $9b,"04",$3b,"35",$48
  1046.  
  1047.         ;sequence for cursor on/off
  1048.  
  1049. con:    dc.b $9b,$20,$70
  1050. coff:   dc.b $9b,$30,$20,$70
  1051.  
  1052. dosname:dc.b "dos.library",0
  1053. trkdisk:dc.b "trackdisk.device",0
  1054. device: dc.b 0
  1055.  
  1056.  align   ;even
  1057. dosbase:dc.l 0
  1058. wdhd:   dc.l 0          ;window handle
  1059.  
  1060. block:  dc.w 880        ;startblock
  1061. offset: dc.l 0          ;offset for read/write =512*block
  1062. buffptr:dc.l 0          ;buffer pointer
  1063. buffer: dc.l 0          ;buffer start
  1064.  
  1065. diskport:
  1066.         dc.l 0          ;0
  1067.         dc.l 0          ;4
  1068.         dc.w $0400      ;8
  1069.         dc.l 0          ;10
  1070.         dc.b 0          ;14
  1071.         dc.b 31         ;15
  1072.         dc.l 0          ;16     task adr. here
  1073. LH1:    dc.l LH2        ;20
  1074. LH2:    dc.l 0          ;24
  1075.         dc.l LH1        ;28
  1076.         dc.b 0          ;32
  1077.         dc.b 0          ;33
  1078.  
  1079. diskioreq:
  1080.         dc.l 0          ;0
  1081.         dc.l 0          ;4
  1082.         dc.b 5          ;8
  1083.         dc.b 0          ;9
  1084.         dc.l 0          ;10
  1085.         dc.l diskport   ;14
  1086.         dc.w 48         ;18
  1087.         dc.l 0          ;20
  1088.         dc.l 0          ;24
  1089.         dc.w 0          ;28 IO_CMD
  1090.         dc.w 0          ;30
  1091.         dc.l 0          ;32 IO_ERROR
  1092.         dc.l 0          ;36 IO_LENGTH
  1093.         dc.l 0          ;40 IO_DATA
  1094.         dc.l 0          ;44 IO_OFFSET
  1095.         dc.l 0
  1096.         dc.l 0
  1097. ;The following is for NTSC versions only, to clear 8 hex lines
  1098. clrhex: dc.b $0a,"                                               "
  1099.         dc.b "                           "
  1100.         dc.b $0a,"                                               "
  1101.         dc.b "                           "
  1102.         dc.b $0a,"                                               "
  1103.         dc.b "                           "
  1104.         dc.b $0a,"                                               "
  1105.         dc.b "                           "
  1106.         dc.b $0a,"                                               "
  1107.         dc.b "                           "
  1108.         dc.b $0a,"                                               "
  1109.         dc.b "                           "
  1110.         dc.b $0a,"                                               "
  1111.         dc.b "                           "
  1112.         dc.b $0a,"                                               "
  1113.         dc.b "                           "
  1114. clrhexend: dc.b 1
  1115. clrhexlen = clrhexend-clrhex
  1116.  end
  1117.  
  1118.